package com.bestcem.xm.ticket.service.dto.dashboard;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;
import java.util.Set;

/**
 * @author zq.ding <zq.ding@idiaoyan.com>
 * @version v1.0
 * @date 2021/8/25 19:09
 */
@Data
public class DashboardDTO {
    /**
     * 工单总数
     */
    @JsonProperty(value = "totalCnt")
    private Long totalCount;

    /**
     * 手动关闭总数
     */
    @JsonProperty(value = "manualClosedCnt")
    private Long manualClosedCnt;

    /**
     * 自动关闭总数
     */
    @JsonProperty(value = "systemClosedCnt")
    private Long systemClosedCnt;

    /**
     * 跟进中数量
     */
    @JsonProperty(value = "followingCnt")
    private Long followingCount;
    /**
     * 保留字段,以前有,现在没有。可视情况去除该属性
     */
    @JsonProperty(value = "auditingCnt")
    private Long auditingCount;

    /**
     * 已关闭数量
     */
    @JsonProperty(value = "closedCnt")
    private Long closedCount;
    /**
     * 处理完成数量
     */
    @JsonProperty(value = "finishCnt")
    private Long finishCount;

    /**
     * 处理失败数量
     */
    @JsonProperty(value = "failCnt")
    private Long failCount;
    /**
     * 预警(无需处理)数量
     */
    @JsonProperty(value = "unNeedDeal")
    private Long unNeedDeal;

    /**
     * 跟进逾期数量
     */
    @JsonProperty(value = "followOverdueCnt")
    private Long followOverdueCount;
    /**
     * 保留字段,以前有,现在没有。可视情况去除该属性
     */
    @JsonProperty(value = "auditOverdueCnt")
    private Long auditOverdueCount;

    /**
     * 用于前端画折线图
     */
    @JsonProperty(value = "newTicketTrends")
    private NewTicketTrends newTicketTrends;
    /**
     * 当前时间,精确到分钟即可
     * 例如:2021-08-25 18:25
     */
    @JsonProperty(value = "updated_dt")
    private String updatedDate;

    /**
     * 统计时间
     */
    @JsonProperty(value = "today")
    private String today;


    @Data
    public static class NewTicketTrends {
        /**
         * 日期范围 前7天到当前日期
         * 例如："2021-08-19", "2021-08-20", "2021-08-21", "2021-08-22", "2021-08-23", "2021-08-24", "2021-08-25"
         */
        @JsonProperty(value = "dateRange")
        private Set<String> dateRange;

        /**
         * 近七日工单数量
         * 例如:"ticketCount": [0, 1, 4, 0, 8, 0, 0],
         */
        @JsonProperty(value = "ticketCount")
        private List<Integer> ticketCount;
        /**
         * 近七日预警数量
         * 例如:"alertCount": [0, 12, 14, 0, 3, 2, 2]
         */
        @JsonProperty(value = "alertCount")
        private List<Integer> alertCount;
    }


    public DashboardDTO() {
        this.totalCount = 0L;
        this.followingCount = 0L;
        this.auditingCount = 0L;
        this.closedCount = 0L;
        this.finishCount = 0L;
        this.failCount = 0L;
        this.unNeedDeal = 0L;
        this.updatedDate = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm").format(LocalDateTime.now());
        this.today = DateTimeFormatter.ofPattern("yyyy/MM/dd").format(LocalDateTime.now());

    }
}
